package com.itboye.ihomebank.activity.home;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.bean.ZuKeDetail;
import com.itboye.ihomebank.custom.RoundImageView;
import com.itboye.ihomebank.presenter.HousePresenter;
import com.itboye.ihomebank.util.ByAlert;
import com.itboye.ihomebank.util.XImageLoader;

import java.util.Observable;
import java.util.Observer;

public class YuYueZuKeDetail extends BaseOtherActivity implements Observer {
	View v_statusbar;
	RoundImageView round;
	ImageView close_icon;
	TextView add_shap_title_tv, txt_name, txt_houseno, txt_phone, txt_mark;
	HousePresenter housePresenter;
	private String house_no;

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.close_icon:
			finish();
			break;
		default:
			break;
		}
	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_zukexinxi;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		setStatusBarHeight(v_statusbar);
		add_shap_title_tv.setText("租客详情");
		house_no = getIntent().getStringExtra("house_no");
		housePresenter = new HousePresenter(this);
		housePresenter.getFangKeXiangQing(house_no);
	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Observable observable, Object data) {
		// TODO Auto-generated method stub
		ResultEntity entity = handlerError(data);
		if (entity != null) {
			if (entity.getEventType() == HousePresenter.fangkedetail_success) {
				ZuKeDetail detail = (ZuKeDetail) entity.getData();
				XImageLoader.load(detail.getHead(), round);
				txt_mark.setText("备注：" + detail.getRemark());
				txt_name.setText("姓名：" + detail.getRealname());
				txt_phone.setText("联系电话：" + detail.getMobile());
				txt_houseno.setText("房源编号：" + detail.getHouseNo());
			} else if (entity.getEventType() == HousePresenter.fangkedetail_fail) {
				ByAlert.alert(entity.getData());
			}
		}
	}

}
